﻿@using Ext.Net;
@using Ext.Net.MVC;
@using InputType = Ext.Net.InputType
@using System.Configuration
@{ 
    var X = Html.X();
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
 
    @Scripts.Render("~/Scripts/mainJs")
 
   

</head>
<body>
   
    @X.ResourceManager().Theme((Theme)int.Parse(ConfigurationManager.AppSettings["theme"].ToString()))
    @RenderBody()
@(X.Viewport()
      .Layout(LayoutType.Border)
      .Items(
          X.Panel()
              .Region(Region.North)
              .Border(false)
              .Split(false)
              .Layout(LayoutType.Fit)
              .Height(50)        
              .ItemsFromAction("Header", "Main")
              .Collapsible(false),
          X.Panel()
              .Region(Region.West)        
              .Width(250)
              .Title("功能导航")
              .Layout(LayoutType.Fit)
              .Split(true)
              .ItemsFromAction("Menu", "Main")
              .Collapsible(true),
          X.TabPanel()
              .Region(Region.Center)
              .ID("MainTabPanel")
              .ItemsFromAction("Content", "Main")
      ))

@(X.Window()
      .ID("WinModCurrentPassword")
      .Title("修改密码")
      .Icon(Icon.TableEdit)
      .Height(300)
      .Width(500)
      .Hidden(true)
      .Modal(true)      
      .Items(
          X.Panel().Layout(LayoutType.VBox)
              .LayoutConfig(new VBoxLayoutConfig { Align = VBoxAlign.Center,Pack = BoxPack.Center})
              .Height(230)
              .Region(Region.Center)
              .Border(false)
              .Items(
                  X.TextField()
                      .ID("txtModCurrentPasswordOld")
                      .FieldLabel("旧密码")
                      .InputType(InputType.Password)
                      .AllowBlank(false),
                  X.TextField()
                      .ID("txtModCurrentPasswordNew")
                      .FieldLabel("新密码")
                      .InputType(InputType.Password)
                      .AllowBlank(false),
                  X.TextField()
                      .ID("txtModCurrentPasswordRepeat")
                      .FieldLabel("重复新密码")
                      .InputType(InputType.Password)
                      .AllowBlank(false)   
              ),
          X.Panel().Layout(LayoutType.HBox)
              .LayoutConfig(new HBoxLayoutConfig{ Align = HBoxAlign.Top,Pack = BoxPack.Center})
              .Region(Region.South)
              .Border(false)
              .Height(40)
              .Items(
                  X.Button()
                  .Text("确定")
                  .ID("btnConfirmModPwd")
                  .Icon(Icon.Accept)
                  .Width(100)
                  .MarginSpec("0 20 0 0")
                      .OnClientClick("ConfirmMod"),                  
                  X.Button()
                      .Text("取消")
                      .ID("btnCancelModPwd")
                      .Icon(Icon.Cancel)
                      .Width(100)
                      .OnClientClick("Clear")
              )         
      ))

<script>
    var maskDiv;
    function ConfirmMod() {
        App.WinModCurrentPassword.mask("处理中...", '', 300);
        if (App.txtModCurrentPasswordNew.getValue() == App.txtModCurrentPasswordRepeat.getValue()) {
            App.direct.ModifyPassword(
                App.txtModCurrentPasswordOld.getValue(),
                App.txtModCurrentPasswordNew.getValue(),
                App.txtModCurrentPasswordRepeat.getValue(), {
                    success: function (result) {
                        if (result.Result != "OK") {
                            Ext.Msg.alert('信息', result.Message);
                            App.WinModCurrentPassword.unmask();
                        } else {
                            Ext.Msg.alert('信息', '修改成功！', function () {
                                App.WinModCurrentPassword.hide();
                            });
                            App.WinModCurrentPassword.unmask();
                        }
                    },
                    failure: function (error) {
                        Ext.Msg.alert('信息', result.Message);
                        App.WinModCurrentPassword.unmask();

                    }
                });
        } else {          
            Ext.Msg.alert('错误', '新的密码与重复密码不一致');
            App.WinModCurrentPassword.unmask();
    }
    }

    function Clear() {
        App.txtModCurrentPasswordOld.setValue(''),
            App.txtModCurrentPasswordNew.setValue(''),
            App.txtModCurrentPasswordRepeat.setValue('');
    }

</script>

</body>
</html>
